package com.lw.extraceim.ui.adapter;


import android.util.Log;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.lw.extraceim.ui.fragments.base.BaseFragment;

import java.util.List;

public class ExtraceFragmentPagerAdapter extends FragmentPagerAdapter {
    private static final String TAG = "ExtraceFragmentPagerAda";
    private List<BaseFragment> fragmentList;
    private List<String> titleList;

    public ExtraceFragmentPagerAdapter(FragmentManager fm, List<BaseFragment> fragmentList, List<String> titleList) {
        super(fm);
        this.fragmentList = fragmentList;
        this.titleList = titleList;
    }

    @Override
    public Fragment getItem(int position) {
        if (fragmentList != null) {
            return fragmentList.get(position);
        } else {
            return null;
        }
    }

    @Override
    public int getCount() {
        if (fragmentList != null) {
            return fragmentList.size();
        } else {
            return 0;
        }

    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        Log.d(TAG, "getPageTitle: " + titleList.size());
        if (titleList != null && titleList.size() > position) {
            return titleList.get(position);
        }

        return null;
    }
}
